package com.ruoyi.web.controller.technician;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.technicianOpus.domain.StoreTechnicianOpus;
import com.ruoyi.technicianOpus.service.IStoreTechnicianOpusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 技师作品Controller
 *
 * @author ch
 * @date 2021-12-02
 */
@RestController
@RequestMapping("/technicianOpus/technicianOpus")
public class StoreTechnicianOpusController extends BaseController
{
    @Autowired
    private IStoreTechnicianOpusService storeTechnicianOpusService;

    /**
     * 查询技师作品列表
     */
    @PreAuthorize("@ss.hasPermi('technicianOpus:technicianOpus:list')")
    @GetMapping("/list")
    public TableDataInfo list(StoreTechnicianOpus storeTechnicianOpus)
    {
        startPage();
        List<StoreTechnicianOpus> list = storeTechnicianOpusService.selectStoreTechnicianOpusList(storeTechnicianOpus);
        return getDataTable(list);
    }

    /**
     * 导出技师作品列表
     */
    @PreAuthorize("@ss.hasPermi('technicianOpus:technicianOpus:export')")
    @Log(title = "技师作品", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StoreTechnicianOpus storeTechnicianOpus)
    {
        List<StoreTechnicianOpus> list = storeTechnicianOpusService.selectStoreTechnicianOpusList(storeTechnicianOpus);
        ExcelUtil<StoreTechnicianOpus> util = new ExcelUtil<StoreTechnicianOpus>(StoreTechnicianOpus.class);
        return util.exportExcel(list, "技师作品数据");
    }

    /**
     * 获取技师作品详细信息
     */
    @PreAuthorize("@ss.hasPermi('technicianOpus:technicianOpus:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(storeTechnicianOpusService.selectStoreTechnicianOpusById(id));
    }

    /**
     * 新增技师作品
     */
    @PreAuthorize("@ss.hasPermi('technicianOpus:technicianOpus:add')")
    @Log(title = "技师作品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StoreTechnicianOpus storeTechnicianOpus)
    {
        return toAjax(storeTechnicianOpusService.insertStoreTechnicianOpus(storeTechnicianOpus));
    }

    /**
     * 修改技师作品
     */
    @PreAuthorize("@ss.hasPermi('technicianOpus:technicianOpus:edit')")
    @Log(title = "技师作品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StoreTechnicianOpus storeTechnicianOpus)
    {
        storeTechnicianOpus.setUpdateType(DicConstants.BUSINESS_Manager.getCode());
        return toAjax(storeTechnicianOpusService.updateStoreTechnicianOpus(storeTechnicianOpus));
    }

    /**
     * 删除技师作品
     */
    @PreAuthorize("@ss.hasPermi('technicianOpus:technicianOpus:remove')")
    @Log(title = "技师作品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(storeTechnicianOpusService.logicDeleteStoreTechnicianOpus(ids,DicConstants.BUSINESS_Manager.getCode(),SecurityUtils.getUserId()));
    }
}
